package com.bfxy.rocketmq.transaction;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

public class TransactionListenerImpl implements TransactionListener {

    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object arg) {
        System.out.println("-------------执行本地事务-------------------");
        String callArg=(String)arg;
        System.out.println("callArg:"+arg);
        System.out.println("message:"+message);
        //begin tx
        //数据库的落库操作
        //tx commit
        return LocalTransactionState.UNKNOW;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("-------------回调消息检查-------------------"+messageExt);
        return LocalTransactionState.COMMIT_MESSAGE;
    }

}
